<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('school/index')}">所有学校</a></li>
        <li><a href="{:url('school/add')}">添加学校</a></li>
        <li  class="active"><a href="{:url('school/edit')}">编辑学校</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form margin-top-20" action="{:url('school/editpost')}" method="post">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学校名称:</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="name" value="{$school.name}">
                <input type="hidden" name="id" value="{$school.id}">
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属省:</label>
            <div class="col-md-6 col-sm-10">
                <select name="province" id="selectSchool" lay-filter="selectSchool" style="width:100%">
                    <foreach name="province" item="vo">
                        <if $school.province == $vo.areaId>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                            <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属市:</label>
            <div class="col-md-6 col-sm-10">
                <select name="city" id="selectRoom" class="valid"  style="width:100%">
                    <foreach name="city" item="vo">
                        <if $school.city == $vo.areaId>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                            <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">所属区县:</label>
            <div class="col-md-6 col-sm-10">
                <select name="district" id="selectCity" class="valid"  style="width:100%">
                    <foreach name="district" item="vo">
                        <if $school.district == $vo.areaId>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                            <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
                <a class="btn btn-default" href="{:url('admin/school/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function () {
        $('#selectSchool').change('click',function () {
            var areaId=$('#selectSchool').val();
            $.ajax({
                url:"{:url('school/getRoom')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    $('#selectRoom').html(res);
                }
            });
        });
    })
</script>
<script>
    $(function () {
        $('#selectRoom').change('click',function () {
            var areaId=$('#selectRoom').val();
            $.ajax({
                url:"{:url('school/getCity')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    $('#selectCity').html(res);
                }
            });
        });
    })
</script>

</body>
</html>